package main;
import java.io.Serializable;

/**
 * The Class Inventory which can be either for a store or for a travel group
 * 
 * modified by: Jarvis.
 */
public class Inventory implements Serializable {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 9130062359386297896L;

	/**The maximum weight the wagon can carry*/
	public static final int MAX_WEIGHT=150;
	
	/** The Constant OXEN_ID. */
	public static final int OXEN_ID=0;
	
	/** The Constant FOOD_ID. */
	public static final int FOOD_ID=1;
	
	/** The Constant CLOTHES_ID. */
	public static final int CLOTHES_ID=2;
	
	/** The Constant WAGON_AXLE_ID. */
	public static final int WAGON_AXLE_ID=3;
	
	/** The Constant WAGON_WHEEL_ID. */
	public static final int WAGON_WHEEL_ID=4;
	
	/** The Constant WAGON_TONGUE_ID. */
	public static final int WAGON_TONGUE_ID=5;
	
	/** The Constant WEIGHTS array */
	protected final int[] WEIGHTS = {0,1,2,4,5,6};
	
	/** The quantity. */
	protected int[] quantity;
	
	/** The total weight of the inventory. */
	protected int totalWeight;
	
	
	/**
	 * Default constructor with default prices.
	 */
	public Inventory() {
		this(new int[]{5,100,100,20,20,20});
		totalWeight=0;
	}
	
	
	/**
	 * Instantiates a new inventory.
	 *
	 * @param quantity the quantity
	 */
	public Inventory(int[] quantity) {
		this.quantity = quantity;
		totalWeight=0;
	}
	
	/**
	 * Instantiates a new inventory.
	 *
	 * @param oxen the number of oxen
	 * @param food the amount of food
	 * @param clothes the amount of clothes
	 * @param axle the number of axles
	 * @param wheel the number of wheels
	 * @param tongue the number of tongues
	 */
	public Inventory(int oxen, int food, int clothes, int axle, int wheel, int tongue) {
		quantity = new int[6];
		quantity[OXEN_ID] = oxen;
		quantity[FOOD_ID] = food;
		quantity[CLOTHES_ID] = clothes;
		quantity[WAGON_AXLE_ID] = axle;
		quantity[WAGON_WHEEL_ID] = wheel;
		quantity[WAGON_TONGUE_ID] = tongue;
		totalWeight=0;
	}

	/**
	 * Calculates the weight. 
	 * 
	 *
	 * @return the int
	 */
	public int calculateWeight() {
		totalWeight = (quantity[FOOD_ID]*WEIGHTS[FOOD_ID] + 
				quantity[CLOTHES_ID]*WEIGHTS[CLOTHES_ID]) +
				quantity[WAGON_AXLE_ID]*WEIGHTS[WAGON_AXLE_ID] +
				quantity[WAGON_WHEEL_ID]*WEIGHTS[WAGON_WHEEL_ID] +
				quantity[WAGON_TONGUE_ID]*WEIGHTS[WAGON_TONGUE_ID];
				
		/*Eventually we need to implement some sort of functionality so that the user can
		 * have at least two wheels, at least 4 axles, and at least 1 tongue
		 * 
		 * if(quantity[WAGON_AXLE_ID]>2){
			totalWeight += quantity[WAGON_AXLE_ID]-2*WEIGHTS[WAGON_AXLE_ID];
		}
		if(quantity[WAGON_WHEEL_ID]>4){
			totalWeight += quantity[WAGON_WHEEL_ID]-4*WEIGHTS[WAGON_WHEEL_ID];
		}
		if(quantity[WAGON_TONGUE_ID]>1){
			totalWeight += quantity[WAGON_TONGUE_ID]-1*WEIGHTS[WAGON_TONGUE_ID];
		}*/
		return totalWeight;
	}
	
	
	/**
	 * Gets the quantity.
	 *
	 * @return the quantity
	 */
	public int[] getQuantity() {
		return quantity;
	}


	/**
	 * Sets the qty.
	 *
	 * @param quantity the new qty
	 */
	public void setQuantity(int[] quantity) {
		this.quantity = quantity;
	}
	
	/**
	 * Gets the qty oxen.
	 *
	 * @return the qty oxen
	 */
	public int getQtyOxen() {
		return quantity[OXEN_ID];
	}


	/**
	 * Sets the qty oxen.
	 *
	 * @param priceOxen the new qty oxen
	 */
	public void setQtyOxen(int priceOxen) {
		quantity[OXEN_ID] = priceOxen;
	}


	/**
	 * Gets the qty food.
	 *
	 * @return the qty food
	 */
	public int getQtyFood() {
		return quantity[FOOD_ID];
	}


	/**
	 * Sets the qty food.
	 *
	 * @param priceFood the new qty food
	 */
	public void setQtyFood(int priceFood) {
		quantity[FOOD_ID] = priceFood;
	}


	/**
	 * Gets the qty clothes.
	 *
	 * @return the qty clothes
	 */
	public int getQtyClothes() {
		return quantity[CLOTHES_ID];
	}


	/**
	 * Sets the qty clothes.
	 *
	 * @param priceClothes the new qty clothes
	 */
	public void setQtyClothes(int priceClothes) {
		quantity[CLOTHES_ID] = priceClothes;
	}


	/**
	 * Gets the qty wagon axle.
	 *
	 * @return the qty wagon axle
	 */
	public int getQtyWagonAxle() {
		return quantity[WAGON_AXLE_ID];
	}


	/**
	 * Sets the qty wagon axle.
	 *
	 * @param priceWagonAxle the new qty wagon axle
	 */
	public void setQtyWagonAxle(int priceWagonAxle) {
		quantity[WAGON_AXLE_ID] = priceWagonAxle;
	}


	/**
	 * Gets the qty wagon wheel.
	 *
	 * @return the qty wagon wheel
	 */
	public int getQtyWagonWheel() {
		return quantity[WAGON_WHEEL_ID];
	}


	/**
	 * Sets the qty wagon wheel.
	 *
	 * @param priceWagonWheel the new qty wagon wheel
	 */
	public void setQtyWagonWheel(int priceWagonWheel) {
		quantity[WAGON_WHEEL_ID] = priceWagonWheel;
	}


	/**
	 * Gets the qty wagon tongue.
	 *
	 * @return the qty wagon tongue
	 */
	public int getQtyWagonTongue() {
		return quantity[WAGON_TONGUE_ID];
	}


	/**
	 * Sets the qty wagon tongue.
	 *
	 * @param priceWagonTongue the new qty wagon tongue
	 */
	public void setQtyWagonTongue(int priceWagonTongue) {
		quantity[WAGON_TONGUE_ID] = priceWagonTongue;
	}
	
	/**
	 * Change total weight.
	 *
	 * @param totalWeight the total weight
	 */
	public void setTotalWeight(int totalWeight) {
		this.totalWeight = totalWeight;
	}

	/**
	 * Gets the total weight.
	 *
	 * @return the total weight
	 */
	public int getTotalWeight() {
		return calculateWeight();
	}

}
